package com.example.demo.controller;

import com.example.demo.exception.BlogException;
import com.example.demo.pojo.dataobject.BlogInfo;
import com.example.demo.pojo.response.BlogInfoDetailResponse;
import com.example.demo.pojo.response.BlogInfoResponse;
import com.example.demo.service.BlogService;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/blog")
@Slf4j
public class BlogController {
    @Resource(name = "blogService")
    private BlogService blogService;
    @RequestMapping("/getList")
    public List<BlogInfoResponse> getList(){
       List<BlogInfoResponse> list= blogService.getList();
       log.info("list:{}",list);
       return  list;
    }

    @RequestMapping("/getBlogDetail")
    public BlogInfoDetailResponse getBlogDetail(@NotNull(message = "blogId不可以为null") Integer blogId){
        log.info("blogId:{}",blogId);
        BlogInfoDetailResponse blogInfoDetailResponse= blogService.getBlogDetail(blogId);
        return blogInfoDetailResponse;
    }

}
